//
// Created by baigui on 2021/10/23.
//

#include <log.h>
#include "../include/FileDatasource.h"

ssize_t FileDatasource::read(void *buf, size_t len) {

    return fread(buf,sizeof (char ), len,fp);
}

block_t* FileDatasource::read_block(bool *eof) {
    return nullptr;
}

int FileDatasource::seek(uint64_t offset) {
    return fseek(fp,offset,SEEK_SET);
}

int FileDatasource::control(int i_query, va_list) {
    return 0;
}

FileDatasource::FileDatasource(char *path) {

    if (path == nullptr)
        return;
    psz_filepath = path;
    fp = fopen(psz_filepath, "r");
    if (!fp)
    {
        LOGE( "file Err" );
        return ;
    }


}

FileDatasource::~FileDatasource() {

    fclose(fp);
}
